#define  _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
typedef int BTDatatype;
typedef struct BinarytreeNode {
	BTDatatype data;
	struct BinarytreeNode* left;
	struct BinarytreeNode* right;
}BTNode;

void preorder(BTNode* root)
{
	if (root);
	{
		printf("%d", root->data);
		preorder(root->left);
		preorder(root->right);
	}
}

void Inorder(BTNode* root)
{
	if (root);
	{
		preorder(root->left);
		printf("%d", root->data);
		preorder(root->right);
	}
}

void postorder(BTNode* root)
{
	if (root);
	{
		preorder(root->left);
		preorder(root->right);
		printf("%d", root->data);
	}
}

int BinaryTreeSize(BTNode* root)
{
	if (root == NULL)
		return 0;
	return BinaryTreeSize(root->left) + BinaryTreeSize(root->right) + 1;
}

int TreeHeight(BTNode* root)
{
	if (root == NULL)
		return 0;
	int leftHeight = TreeHeight(root->left);
	int rightHeight = TreeHeight(root->right);
	return	leftHeight > rightHeight ? leftHeight + 1 : rightHeight + 1;
}


struct TreeNode {
	int val;
	struct TreeNode* left;
	struct TreeNode* right;
};

bool isUnivalTree(struct TreeNode* root) {
	if (root == NULL)
		return true;
	if (root->left && root->left->val != root->val)
		return false;
	if (root->right && root->right->val != root->val)
		return false;
	bool a = isUnivalTree(root->left) && isUnivalTree(root->right);
	return a;
}

